aux_source_directory(. SRCS_MAIN)
add_executable(${PROJECT_NAME} ${SRCS_MAIN})

# 链接动态库
target_link_libraries(${PROJECT_NAME}
    fmt::fmt
    ${lib_person_name}
    ${lib_util_name}
    ${lib_configuration_name}
)

# 可执行程序生成目录
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${bin_dir})

# 设置 rpath
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "\${ORIGIN}/../lib")

# 构建后动作
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD

    # 复制启动脚本
    COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/resources/${PROJECT_NAME} ${sbin_dir}/${PROJECT_NAME}

    # 复制动态库文件
    COMMAND cp -rp ${fmt_DIRECTORY}/lib* ${lib_dir}
    COMMAND cp -rp ${spdlog_DIRECTORY}/lib* ${lib_dir}
)
